package h0809;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
/**
  * @description 伐木工
  * @author 不知名帅哥
  * @date 2024/8/9 12:22
  * @version 1.0
*/
public class MaxProfitCutting {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        scanner.close();

        ArrayList<Integer> result = maxProfit(X);

        // 输出结果
        for (int i = 0; i < result.size(); i++) {
            System.out.print(result.get(i));
            if (i < result.size() - 1) {
                System.out.print(" ");
            }
        }
    }

    private static ArrayList<Integer> maxProfit(int X) {
        // dp数组用于记录每个长度的最大收益
        int[] dp = new int[X + 1];
        // cuts数组用于记录每个长度的最少切割次数
        int[] cuts = new int[X + 1];
        // solution数组用于记录每个长度的最优切割点
        int[] solution = new int[X + 1];

        // 初始化dp数组和cuts数组
        for (int i = 1; i <= X; i++) {
            dp[i] = i;
            cuts[i] = 0;
        }

        // 动态规划计算最大收益和最少切割次数
        for (int i = 1; i <= X; i++) {
            for (int j = 1; j < i; j++) {
                int profit = dp[j] * dp[i - j];

                if (dp[i] < profit) {
                    dp[i] = profit;
                    cuts[i] = cuts[j] + cuts[i - j] + 1;
                    solution[i] = j;
                } else if (dp[i] == profit) {
                    //有更优切割方案，更新solution[i]
                    if (cuts[i] > cuts[j] + cuts[i - j] + 1) {
                        //更新切割次数
                        cuts[i] = cuts[j] + cuts[i - j] + 1;
                        solution[i] = j;
                    }
                }
            }
        }

        // 回溯最优切割方案
        ArrayList<Integer> result = new ArrayList<>();
        int length = X;
        while (length > 0) {
            if (solution[length] == 0) {
                result.add(length);
                break;
            }
            result.add(solution[length]);
            length -= solution[length];
        }

        Collections.sort(result);  // 按升序排序
        return result;
    }
}
